@file:Suppress("SpellCheckingInspection")

package han.cirno.corrupt.components.school.impl.fafu

import han.cirno.corrupt.data.instances.UserScoreData.Score
import org.jsoup.Jsoup

object FafuScoreResolver {
    fun analyse(htmlString: String):List<Score>{
        val document = Jsoup.parse(htmlString)
        val dataGird = document.getElementById("DataGrid1")!!.children()
        val scores=ArrayList<Score>()
        dataGird[0].children().forEach {
            if(it.attr("class")=="datelisthead")return@forEach
            val attrs=it.children().map { c-> c.text() }
            scores.add(Score(
                year = attrs[0],
                term = attrs[1],
                code = attrs[2],
                name = attrs[3],
                property = attrs[4],
                belonging = attrs[5],
                credits = attrs[6],
                score = attrs[7],
                reExamScore = attrs[8],
                isReBuild = attrs[9],
                place = attrs[10],
                gp = attrs[11],
                note = attrs[12],
                reExamNote = attrs[13],
                optional = attrs[4].contains("选修")
            ))
        }
        return scores
    }
}